﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基础信息</title>
    <link href="http://g.alicdn.com/bui/bui/1.1.21/css/bs3/dpl.css" rel="stylesheet">
    <link href="http://g.alicdn.com/bui/bui/1.1.21/css/bs3/bui.css" rel="stylesheet">
</head>
<body>
    <div class="demo-content">
        <div class="doc-content">
            <hr>
            <form action="" class="form-horizontal form-horizontal-simple">
                <div class="control-group">
                    <label class="control-label">账号：</label>
                    <div class="controls">
                        <span class="control-text">@ViewBag.Account</span>
                    </div>
                </div>
                <div class="actions-bar">
                    <div class="row form-actions ">
                        <div class="span13 offset3 ">
                            <input type="button" id="changePwd" class="button button-primary" value="修改密码" />
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div id="pwdContent" class="hidden" style="display:none;">
        <form id="form" class="form-horizontal">
            <div class="row">
                <div class="control-group span8">
                    <label class="control-label">旧密码：</label>
                    <div class="controls">
                        <input type="password" class="input-normal control-text" id="oldPwd" data-rules="{required : true}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span8">
                    <label class="control-label">新密码：</label>
                    <div class="controls">
                        <input type="password" class="input-normal control-text" id="newPwd" data-rules="{required : true}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span8">
                    <label class="control-label">新密码确认：</label>
                    <div class="controls">
                        <input type="password" class="input-normal control-text" id="newPwdConfirm" data-rules="{required : true}">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <script src="http://g.tbcdn.cn/fi/bui/jquery-1.8.1.min.js"></script>
    <script src="http://g.alicdn.com/bui/seajs/2.3.0/sea.js"></script>
    <script src="http://g.alicdn.com/bui/bui/1.1.21/config.js"></script>
    <script>
        BUI.use(['bui/overlay', 'bui/form'], function (Overlay, Form) {
            var form = new Form.HForm({
                srcNode: '#form'
            }).render();

            var dialog = new Overlay.Dialog({
                title: '密码修改',
                width: 500,
                height: 320,
                contentId: 'pwdContent',
                success: function () {
                    var oldPwd = $.trim($("#oldPwd").val());
                    var newPwd = $("#newPwd").val();
                    var newPwdConfirm = $("#newPwdConfirm").val();
                    if (oldPwd == "") {
                        BUI.Message.Alert('请输入旧密码', 'warning');
                        return;
                    }

                    if (newPwd == "") {
                        BUI.Message.Alert('请输入新密码', 'warning');
                        return;
                    }

                    if (newPwd != newPwdConfirm) {
                        BUI.Message.Alert('两次密码输入不一致', 'warning');
                        return;
                    }

                    $.post("/user/changecurrentuserpwd", { oldPwd: oldPwd, newPwd: newPwd, newPwdConfirm: newPwdConfirm }, function (res) {
                        if (res.success) {
                            $("#oldPwd").val("");
                            $("#newPwd").val("");
                            $("#newPwdConfirm").val("");
                            BUI.Message.Alert('修改密码成功', function () {
                                dialog.close();
                            }, 'info');
                        }
                        else {
                            BUI.Message.Alert('修改密码失败:' + res.message, 'warning');
                        }
                    })
                }
            });

            $('#changePwd').on('click', function () {
                dialog.show();
            });
        });
    </script>
</body>
</html>  